package com.study.blogsearchconsumer.service;

import com.study.blogsearchpojo.entity.Blog;
import com.study.blogsearchpojo.entity.BlogBatchDto;
import com.study.blogsearchpojo.entity.BlogOneDto;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@FeignClient(name = "blog-search-producer")
public interface SearchFeignService {
    /**
     * 判断索引库是否已经存在
     */
    @PostMapping("/exists")
    @ResponseBody
    boolean exists(@RequestParam(value = "indexName") String indexName);

    /**
     * 删除索引库
     */
    @PostMapping("/dropIndex")
    @ResponseBody
    boolean dropIndex(@RequestParam(value = "indexName")String indexName);

    /**
     * 创建博客索引库（标题、内容、作者、博客id） （标题、内容、作者可以分词检索）
     */
    @PostMapping("/createBlogIndex")
    @ResponseBody
    boolean createBlogIndex(@RequestParam(value = "indexName")String indexName);


    /**
     * 录入一条博客
     */
    @PostMapping("/saveOne")
    @ResponseBody
    boolean saveOne(@RequestBody BlogOneDto blogOneDto);
    /**
     * 批量录入博客
     */
    @PostMapping("/addBlogsInBatches")
    @ResponseBody
    boolean addBlogsInBatches(@RequestBody BlogBatchDto blogBatchDto);
    /**
     * 判断一条是否存在
     */
    @PostMapping("/existsOne")
    @ResponseBody
    boolean existsOne(@RequestParam(value = "indexName")String indexName, @RequestParam(value = "id")String id);
    /**
     * 删除一条
     */
    @PostMapping("/deleteOne")
    @ResponseBody
    boolean deleteOne(@RequestParam(value = "indexName")String indexName, @RequestParam(value = "id")String id);
    /**
     * 更新一条博客
     */
    @PostMapping("/updateOne")
    @ResponseBody
    boolean updateOne(@RequestBody BlogOneDto blogOneDto);
    /**
     * 根据关键词  将标题、作者、内容与搜索词相关的博客检索出来
     */
    @PostMapping("/search")
    @ResponseBody
    List<Blog> search(@RequestParam(value = "indexName") String indexName,@RequestParam(value ="keyword" ) String keyword,@RequestParam(value="pageNo")int pageNo);
//    /**
//     * 根据关键词  将标题、作者、内容与搜索词相关的博客检索出来
//     */
//    @PostMapping("/suggest")
//    @ResponseBody
//    List<String> suggest(String indexName, String keyword);
}
